﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MyDBconnection;

namespace Thesis_2
{
    public partial class frmSupplierlist : Form
    {
        DatabaseConnection dbcon = new DatabaseConnection();
        public frmSupplierlist()
        {
            InitializeComponent();
            this.Load += new EventHandler(frmSupplierlist_Load);
            dataGridView1.RowHeaderMouseClick += new DataGridViewCellMouseEventHandler(dataGridView1_RowHeaderMouseClick);
        }

        void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            DataGridViewRow dr = dataGridView1.SelectedRows[0];
            frmSupplierEntry frmS = new frmSupplierEntry();
            frmS.Show();
            this.Hide();
            frmS.txtSupplierID.Text = dr.Cells[0].Value.ToString();
            frmS.txtSupplierName.Text = dr.Cells[1].Value.ToString();
            frmS.txtAddress.Text = dr.Cells[2].Value.ToString();
            frmS.txtContactNo.Text = dr.Cells[3].Value.ToString();
            frmS.txtLandline.Text = dr.Cells[4].Value.ToString();
            frmS.txtEmail.Text = dr.Cells[5].Value.ToString();
            frmS.btnSave.Enabled = false;
            frmS.btnUpdate.Enabled = true;

        }

        void frmSupplierlist_Load(object sender, EventArgs e)
        {
            getDate();
            dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }


        void getDate()
        {
            dbcon.dbconnection();
            dbcon.loadData("Select distinct SupplierID,SupplierName,Address,Contactno,LandLine,Email,Encodedby from tblsupplier");
            dataGridView1.DataSource = dbcon.tbl;
            dbcon.DBClose();
        
        }
    }
}
